package com.huike.web.controller.report;


import com.huike.common.utils.DateUtils;
import com.huike.common.utils.SecurityUtils;
import com.huike.report.domain.vo.IndexTodayInfoVO;
import com.huike.report.domain.vo.IndexTodoInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
    }

    /**
     * 首页今日简报部分数
     * @return
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo(){
        IndexTodayInfoVO indexTodayInfoVO =reportService.getTodayInfo(DateUtils.getTime(), SecurityUtils.getUsername());
        return AjaxResult.success(indexTodayInfoVO);
    }


    /**
     * 首页待办数据统计接口
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(
            @RequestParam("beginCreateTime") String beginCreateTime,
            @RequestParam("endCreateTime") String endCreateTime
    ){
        IndexTodoInfoVO indexTodoInfoVO =reportService.getTodoInfo(beginCreateTime,endCreateTime,SecurityUtils.getUsername());
        return AjaxResult.success(indexTodoInfoVO);
    }

    /**
     * 首页--商机转化龙虎榜接口
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(
            @RequestParam("beginCreateTime") String beginCreateTime,
            @RequestParam("endCreateTime") String endCreateTime
    ){
        List<Map<String,Object>> mapList =reportService.businessChangeStatistics(beginCreateTime,endCreateTime);
        return AjaxResult.success(mapList);
    }

    /**
     * 线索转化龙虎榜接口
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistic(
            @RequestParam("beginCreateTime") String beginCreateTime,
            @RequestParam("endCreateTime") String endCreateTime
    ){
        List<Map<String,Object>> mapList =reportService.salesStatistic(beginCreateTime,endCreateTime);
        return AjaxResult.success(mapList);
    }

}